home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 26 / AACD 26.iso / AACD / Programming / ace_gpl_release / src_ansi / ace / c / iff.c < prev    next >
Encoding:
C/C++ Source or Header  |  1999-01-05  |  3.1 KB  |  181 lines

  1. /*
  2.    ** ACE IFF commands.
  3.    ** Copyright (C) 1998 David Benn
  4.    ** 
  5.    ** This program is free software; you can redistribute it and/or
  6.    ** modify it under the terms of the GNU General Public License
  7.    ** as published by the Free Software Foundation; either version 2
  8.    ** of the License, or (at your option) any later version.
  9.    **
  10.    ** This program is distributed in the hope that it will be useful,
  11.    ** but WITHOUT ANY WARRANTY; without even the implied warranty of
  12.    ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13.    ** GNU General Public License for more details.
  14.    **
  15.    ** You should have received a copy of the GNU General Public License
  16.    ** along with this program; if not, write to the Free Software
  17.    ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
  18.    **
  19.    ** Author: David J Benn
  20.    **   Date: 27th February 1994,
  21.    **      10th,11th,19th August 1994
  22.  */
  23.  
  24. #include "acedef.h"
  25.  
  26. /* externals */
  27. extern int sym;
  28. extern BOOL iffused;
  29.  
  30. /* functions */
  31. void iff_open (void)
  32. {
  33. /* 
  34.    ** IFF OPEN [#]channel,file-name
  35.  */
  36.   int itype;
  37.  
  38.   insymbol ();
  39.  
  40.   if (sym == hash)
  41.     insymbol ();
  42.  
  43.   itype = expr ();
  44.  
  45.   if (itype == stringtype)
  46.     _error (4);
  47.   else
  48.     {
  49.       /* channel */
  50.       if (make_integer (itype) == shorttype)
  51.     make_long ();
  52.  
  53.       if (sym != comma)
  54.     _error (16);
  55.       else
  56.     {
  57.       /* picture file name */
  58.       insymbol ();
  59.       if (expr () != stringtype)
  60.         _error (4);
  61.       else
  62.         {
  63.           /* call function */
  64.           gen ("jsr", "_IFFPicOpen", "  ");
  65.           gen ("addq", "#8", "sp");
  66.           enter_XREF ("_IFFPicOpen");
  67.         }
  68.     }
  69.  
  70.     }
  71. }
  72.  
  73. void iff_read (void)
  74. {
  75. /* 
  76.    ** IFF READ [#]channel[,screen-id]
  77.  */
  78.   int itype;
  79.  
  80.   insymbol ();
  81.  
  82.   if (sym == hash)
  83.     insymbol ();
  84.  
  85.   itype = expr ();
  86.  
  87.   if (itype == stringtype)
  88.     _error (4);
  89.   else
  90.     {
  91.       /* channel */
  92.       if (make_integer (itype) == shorttype)
  93.     make_long ();
  94.  
  95.       if (sym != comma)
  96.     /* no screen-id */
  97.     gen ("move.l", "#-1", "-(sp)");
  98.       else
  99.     {
  100.       /* screen-id */
  101.  
  102.       insymbol ();
  103.  
  104.       itype = expr ();
  105.  
  106.       if (itype == stringtype)
  107.         _error (4);
  108.       else
  109.         {
  110.           if (make_integer (itype) == shorttype)
  111.         make_long ();
  112.  
  113.         }
  114.     }
  115.  
  116.       /* call function */
  117.       gen ("jsr", "_IFFPicRead", "  ");
  118.       gen ("addq", "#8", "sp");
  119.       enter_XREF ("_IFFPicRead");
  120.     }
  121. }
  122.  
  123. void iff_close (void)
  124. {
  125. /* 
  126.    ** IFF CLOSE [#]channel
  127.  */
  128.   int itype;
  129.  
  130.   insymbol ();
  131.  
  132.   if (sym == hash)
  133.     insymbol ();
  134.  
  135.   itype = expr ();
  136.  
  137.   if (itype == stringtype)
  138.     _error (4);
  139.   else
  140.     {
  141.       /* channel */
  142.       if (make_integer (itype) == shorttype)
  143.     make_long ();
  144.  
  145.       /* call function */
  146.       gen ("jsr", "_IFFPicClose", "  ");
  147.       gen ("addq", "#4", "sp");
  148.       enter_XREF ("_IFFPicClose");
  149.     }
  150. }
  151.  
  152. void iff (void)
  153. {
  154. /* IFF OPEN | READ | CLOSE */
  155.  
  156.   insymbol ();
  157.  
  158.   switch (sym)
  159.     {
  160.     case opensym:
  161.       iff_open ();
  162.       break;
  163.     case readsym:
  164.       iff_read ();
  165.       break;
  166.     case closesym:
  167.       iff_close ();
  168.       break;
  169.     }
  170.  
  171.   /* 
  172.      ** All three require intuition.library.
  173.    */
  174.   enter_XREF ("_IntuitionBase");
  175.  
  176.   /*
  177.      ** We need to tell ACE to create/delete ILBM.library.
  178.    */
  179.   iffused = TRUE;
  180. }
  181.